package cn.tedu.boke.portal.mapper;

import cn.tedu.boke.portal.model.Post;
import cn.tedu.boke.portal.vo.PostLabelsVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * 帖子 Mapper 接口
 * </p>
 *
 * @author xdoor
 * @since 2021-11-05
 */
@Repository
public interface PostMapper extends BaseMapper<Post>
{
    List<PostLabelsVo> findAllPosts();

    @Select("SELECT u.username ,u.nickname,u.url,p.id,p.title,p.createtime, \n" +
            "p.content,p.viewnum,p.likenum,p.commentnum \n" +
            "FROM user u \n" +
            "RIGHT JOIN post p ON p.user_id=u.id WHERE p.id=#{id} and p.delete_status=0")
    PostLabelsVo findOnePost(Integer id);

}
